import { http } from '@/utils/http/axios';

export interface BasicResponseModel<T = any> {
  code: number;
  msg: string;
  data: T;
}

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}

/**
 * @description: 修改用户权限列表
 * @param params 参数列表  name: 姓名, email: 邮箱
 */
export function getUserList(params?) {
  return http.request({
    url: '/disk/admin/user/getUserList',
    method: 'GET',
    params,
  });
}


/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return http.request({
    // url: '/admin_info',
    url: '/disk/admin/user/getUserInfo',
    method: 'get',
  });
}

/**
 * @description: 用户登录
 */
export function login(params) {
  return http.request<BasicResponseModel>(
    {
      // url: '/login',
      url: '/disk/admin/user/login',
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * @description: 用户修改密码
 */
export function changePassword(params, uid) {
  return http.request(
    {
      url: `/user/u${uid}/changepw`,
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * @description: 用户登出
 */
export function logout(params) {
  return http.request({
    url: '/login/logout',
    method: 'POST',
    params,
  });
}

/**
 * @description: 修改用户权限列表
 */
export function updatePermissions(params: []) {
  return http.request({
    url: '/disk/admin/user/updatePermissions',
    method: 'POST',
    params,
  });
}

/**
 * @description: 根据用户id修改用户权限列表
 */
export function updatePermissionsById(userId: String, params: []) {
  let response = http.request({
    url: `/disk/admin/user/updatePermissions/${userId}`,
    method: 'PUT',
    params,
  });
  console.log('response', response)
  return response;
}
/**
 * 删除菜单
 * @param id 菜单id
 */
export function deleteById(id) {
  return http.request({
    url: `/disk/admin/user/delete/${id}`,
    method: 'DELETE',
  });
}
